import { fechCartStatus } from '_api'
import { getToken } from '_utils/token.js'
export default {
  namespaced: true,
  state: {
    // 购物车的商品
    item: [],
    number: 0
  },
  mutations: {
    set_info (state, { item, number }) {
      // 修改购物车数据
      state.item = item
      state.number = number
    }
  },
  actions: {
    getInfo ({ commit }, state) {
      fechCartStatus({
        token: getToken()
      }).then(res => {
        commit('set_info', { item: res.data.data.items, number: res.data.data.number })
      })
    }
  }
}
